home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
PROGRAMM
/
PASCAL
/
0920.ZIP
/
PRINTR.ARC
/
PRINTER.DOC
next >
Wrap
Text File
|
1988-01-24
|
3KB
|
63 lines
{ PRINTER -- A replacement unit for the standard Turbo 4 PRINTER unit.
Version 1.0 - 1/24/1988 - First general release
Scott Bussinger
Professional Practice Systems
110 South 131st Street
Tacoma, WA 98444
(206)531-8944
Compuserve 72247,2671
This UNIT for Turbo Pascal version 4.0 replaces the standard PRINTER unit in
provided with the compiler and solves some problems related to sending printer
control strings and graphics data to printers using the LST file.
DOS supports two modes of access to files and devices. These are either
RAW and COOKED modes (or BINARY and ASCII modes, depending on what reference
you are looking at) and control the way that data being written or read is
interpreted by DOS itself. For example in COOKED mode, all tabs that output
are converted into spaces and ^C will stop the program. In RAW mode, data is
passed directly to the file or device with no special interpretation.
The PRINTER unit supplied with Turbo Pascal version 4.0 simply opens a DOS
handle pointing to the printer device and lets DOS use the default COOKED
mode. The problem arises that if you try and send a ^Z (or #26 or chr(26)) in
this mode, all further output to the printer is lost. The reason is that DOS
is interpreting the ^Z as an end of file (EOF) marker and closes the output
device. The solution is simple -- just change the printer file to RAW mode.
Since there is no reason to interpret the codes being sent to the printer
anyway, this works fine.
This unit does just that and then restores the original value of the
COOKED/RAW flag just to be sure no other programs get confused. The easiest
way to use this unit is to compile it to disk and replace the standard PRINTER
unit in the TURBO.TPL file. If you don't at least remove the original PRINTER
unit from TURBO.TPL file, then this unit will never be used.
To replace the PRINTER unit, go to the directory containing all of your
Turbo files and first be sure you are not working with your master disks. ONLY
DO THESE CHANGES TO A COPY OF THE TURBO.TPL FILE! Put a compiled version of
the new PRINTER unit in the directory (that will be the PRINTER.TPU file).
Now run the library utility program as follows:
TPUMOVER TURBO /-PRINTER /+PRINTER
This deletes the original PRINTER unit and adds the new PRINTER unit to the
TURBO.TPL file. You can also delete the PRINTER.TPU file now.
Having made these changes, you should be able to use the PRINTER unit
exactly as documented in the Turbo Pascal manual, except that it will now work
in all cases.
If you compile and run this DOC file, it will test that you have
successfully compiled and installed the new PRINTER unit. If you run this
program on a machine with a printer attached, you should see TWO output lines.
If run on an un-replaced TURBO.TPL, you'll see only one line. Since the ^Z is
being sent to your printer and this can have different effects on different
printers, you may instead see both lines of information stuck together or in a
different font or something. This is a fine indication and means the fix did
work, but I suggest you turn off your printer to make sure it hasn't been left
in a strange mode. }
program Test;
uses Printer;
begin
writeln(Lst,'This is the first line and will always show up.');
writeln(Lst,^Z'This line only shows up with the new PRINTER unit.')
end.